package com.haidong.myfile.Listener;

import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

public class MyMouseListen implements MouseListener {
    //不管什么鼠标操作都要保证光标始终在最后
    @Override
    public void mouseClicked(MouseEvent e) {
        TextArea field = (TextArea) e.getSource();
        field.setCaretPosition(field.getText().length());
    }
    @Override
    public void mousePressed(MouseEvent e) {
        TextArea field = (TextArea) e.getSource();
        field.setCaretPosition(field.getText().length());
    }
    @Override
    public void mouseReleased(MouseEvent e) {
        TextArea field = (TextArea) e.getSource();
        field.setCaretPosition(field.getText().length());
    }
    @Override
    public void mouseEntered(MouseEvent e) {
        TextArea field = (TextArea) e.getSource();
        field.setCaretPosition(field.getText().length());
    }
    @Override
    public void mouseExited(MouseEvent e) {
        TextArea field = (TextArea) e.getSource();
        field.setCaretPosition(field.getText().length());
    }
}
